<?php
include "lib/getLoginID.php";
require_once('lib/ftree_utils.php');
require_once "HTML/Template/IT.php";

// GET HTTP "GET" VARS

if ( isset($_GET['id']) ) {
        $id = $_GET['id'];
} else {
        $id = getLoginID();
}
$id=preg_replace("/[^0-9]/","",$id);  //get rid of anything but numbers
if ($id < 1 || $id > pow(2,17)) {
        $id = 3054; //when in doubt, go to my card
}

if ( isset($_GET['view']) ) {
        $view = $_GET['view'];
} else {
        $view = "detail";
}
if ( isset($_GET['opt']) ) {
        $opt = $_GET['opt'];
} else {
        $opt = "";
}

// SET UP TEMPLATE

$isMobile = ChkIsMobile();
$tpl = new HTML_Template_IT("templates");
$status = $tpl->loadTemplatefile("main_tmpl.html", true, true);

// FILL TEMPLATE

switch ($view) {
	case "tree":
		$main = "tree.php?id=$id";
		break;
	case "cal":
		$main = "cal.php?m=$opt";
		break;
	case "media":
		$main = "person_media.php?id=$id";
		break;
	default:
		$main = "person.php?id=$id";
		break;
}

$cont = "index.php";
$tpl->setVariable("MainFrame", $main);
$tpl->setVariable("ContentsFrame", $cont);

if ($isMobile) {
	header("Location: $main");
} else {
	$tpl->show();
}

?>
